package com.example.mypassword.bean;

import lombok.*;
import org.hibernate.Hibernate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * @description: 用户实体类
 * @author: fengfazheng
 * @create: 2021-12-26 19:54
 **/
@Entity
@Table(name = "user")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
public class User implements Serializable {

    private static final long serialVersionUID = 4183634906300829075L;
    @Id
    private String id;

    @Column(name = "USERNAME", length = 256)
    private String username;

    @Column(name = "PASSWORD",  length = 256)
    private String password;

    @Column(name = "LEVEL", length = 1)
    private String level;

    @Column(name = "PHONE", length = 13)
    private String phone;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        User user = (User) o;
        return id != null && Objects.equals(id, user.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}


